<?php

// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议 https://mit-license.org
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller\system;

use app\admin\model\SystemUploadfile;
use app\common\controller\AdminController;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;

/**
 * @ControllerAnnotation(title="上传文件管理")
 * Class Uploadfile
 *
 * @package app\admin\controller\system
 */
class Uploadfile extends AdminController
{
    
    use \app\admin\traits\Curd;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new SystemUploadfile();
    }

    /**
     * @NodeAnotation(title="列表")
     */
    public function index()
    {
        if (input('selectFields')) {
            return $this->selectList();
        }
        list ($page, $limit, $where) = $this->buildTableParames();
        
        if (! empty(input('type'))) {
            $where[] = [
                "type",
                "=",
                input('type')
            ];
        }
        
        $count = $this->model->where($where)->count();
        $list = $this->model->where($where)
            ->page($page, $limit)
            ->order($this->sort)
            ->select();
        
        return msg([
            'list' => $list,
            'count' => $count
        ], 0, "success");
    }
}